/*
 * File: uMultiWordMul.c
 *
 * Code generated for Simulink model 'TABL'.
 *
 * Model version                  : 3.213
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Thu Apr 28 14:14:16 2022
 */

#include "rtwtypes.h"
#include "uMultiWordMul.h"

void uMultiWordMul(const uint32_T u1[], int32_T n1, const uint32_T u2[], int32_T
                   n2, uint32_T y[], int32_T n)
{
    int32_T i;
    int32_T j;
    int32_T k;
    int32_T ni;
    uint32_T a0;
    uint32_T a1;
    uint32_T b1;
    uint32_T cb;
    uint32_T u1i;
    uint32_T w01;
    uint32_T w10;
    uint32_T yk;

    /* Initialize output to zero */
    for (k = 0; k < n; k++)
    {
        y[k] = 0U;
    }

    for (i = 0; i < n1; i++)
    {
        cb = 0U;
        u1i = u1[i];
        a1 = u1i >> 16U;
        a0 = u1i & 65535U;
        ni = n - i;
        ni = n2 <= ni ? n2 : ni;
        k = i;
        for (j = 0; j < ni; j++)
        {
            u1i = u2[j];
            b1 = u1i >> 16U;
            u1i &= 65535U;
            w10 = a1 * u1i;
            w01 = a0 * b1;
            yk = y[k] + cb;
            cb = (uint32_T)(yk < cb);
            u1i *= a0;
            yk += u1i;
            cb += (yk < u1i);
            u1i = w10 << 16U;
            yk += u1i;
            cb += (yk < u1i);
            u1i = w01 << 16U;
            yk += u1i;
            cb += (yk < u1i);
            y[k] = yk;
            cb += w10 >> 16U;
            cb += w01 >> 16U;
            cb += a1 * b1;
            k++;
        }

        if (k < n)
        {
            y[k] = cb;
        }
    }
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
